package com.yby.mall.product.controller;

import java.util.Arrays;
import java.util.Map;

import com.yby.common.utils.PageUtils;
import com.yby.mall.product.vo.CategoryBrandRelationVo;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.yby.mall.product.entity.CategoryBrandRelationEntity;
import com.yby.mall.product.service.CategoryBrandRelationService;
import com.yby.common.utils.R;



/**
 * 品牌分类关联
 *
 * @author yangbingying
 * @email 2771355658@qq.com
 * @date 2021-07-09 20:49:20
 */
@Api(value = "", tags = "品牌分类关联")
@RestController
@RequestMapping("/product/categorybrandrelation")
public class CategoryBrandRelationController {
    @Autowired
    private CategoryBrandRelationService categoryBrandRelationService;

    /**
     * 列表
     */
    @GetMapping("/catelog/list")
    public R list(Long brandId){
        return categoryBrandRelationService.queryPage(brandId);
    }


    @GetMapping("/brands/list")
    public R brandsList(Long catId){
        return categoryBrandRelationService.brandsList(catId);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Long id){
		CategoryBrandRelationEntity categoryBrandRelation = categoryBrandRelationService.getById(id);
        return R.ok().put("categoryBrandRelation", categoryBrandRelation);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody CategoryBrandRelationVo categoryBrandRelationVo){

        return categoryBrandRelationService.saveCategoryBrandRelation(categoryBrandRelationVo);
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody CategoryBrandRelationEntity categoryBrandRelation){
		categoryBrandRelationService.updateById(categoryBrandRelation);
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] ids){
		categoryBrandRelationService.removeByIds(Arrays.asList(ids));
        return R.ok();
    }

}
